<p>According to the documentation of the Java <code>Condition</code> interface:</p>
<blockquote>
  <p>When waiting upon a <code>Condition</code>, a "spurious wakeup" is permitted to occur, in general, as a concession to the underlying platform
  semantics. This has little practical impact on most application programs as a Condition should always be waited upon in a loop, testing the state
  predicate that is being waited for. An implementation is free to remove the possibility of spurious wakeups but it is recommended that applications
  programmers always assume that they can occur and so always wait in a loop.</p>
</blockquote>
<p>The same advice is also found for the <code>Object.wait(...)</code> method:</p>
<blockquote>
  <p>waits should always occur in loops, like this one:</p>
  <pre>
synchronized (obj) {
  while (&lt;condition does not hold&gt;){
    obj.wait(timeout);
  }
   ... // Perform action appropriate to condition
}
</pre>
</blockquote>
<h2>Noncompliant Code Example</h2>
<pre>
synchronized (obj) {
  if (!suitableCondition()){
    obj.wait(timeout);   //the thread can wake up even if the condition is still false
  }
   ... // Perform action appropriate to condition
}
</pre>
<h2>Compliant Solution</h2>
<pre>
synchronized (obj) {
  while (!suitableCondition()){
    obj.wait(timeout);
  }
   ... // Perform action appropriate to condition
}
</pre>
<h2>See</h2>
<ul>
  <li> <a href="https://wiki.sei.cmu.edu/confluence/x/EzdGBQ">CERT THI03-J.</a> - Always invoke wait() and await() methods inside a loop </li>
</ul>

